var t = getApp();

Page({
    data: {
        member_voucher_id: "",
        max_price: "",
        min_price: "",
        value: "",
        title: "",
        tabs: [ "全部", "未寄售", "寄售中", "已出售", "自行寄回" ],
        active: 0,
        text: "",
        list: [],
        is_custom: 1,
        show: !1,
        page: 1,
        total_page: 0
    },
    onLoad: function() {
        this.setData({
            show: !1,
            active: 0,
            member_voucher_id: ""
        }), this.getData();
    },
    handle_conset: function(e) {
        var a = this, i = e.currentTarget.dataset.item;
        t._postNetWork({
            url: t.getNetAddresss("plugin.consignment.frontend.controllers.member-exchange-voucher.is-agree"),
            data: {
                member_voucher_id: i.id
            },
            success: function(e) {
                var i = e.data;
                t.tips(i.msg), i.result && a.getData(1);
            }
        });
    },
    input_handle: function(t) {
        this.setData({
            value: t.detail
        });
    },
    confirm: function() {
        var e = this;
        t._postNetWork({
            url: t.getNetAddresss("plugin.consignment.frontend.controllers.member-exchange-voucher.sold"),
            data: {
                member_voucher_id: this.data.member_voucher_id,
                price: this.data.value
            },
            success: function(a) {
                var i = a.data;
                t.tips(i.msg), i.result && e.getData(1);
            }
        });
    },
    check_orders: function(t) {
        var e = t.currentTarget.dataset.item, a = "/packageA/member/orderdetail/orderdetail?order_id=".concat(e.sold_order_id, "&orderType=shop&show_detail_pay=0");
        wx.navigateTo({
            url: a
        });
    },
    show_dialog: function(t) {
        var e = t.currentTarget.dataset.item, a = e.exchange_voucher, i = a.max_price, s = a.min_price, r = a.is_custom, o = e.can_sold, n = e.id;
        o && (1 == r ? this.setData({
            value: "",
            title: "寄售设置"
        }) : this.setData({
            value: "",
            title: "是否确认寄售商品"
        }), this.setData({
            show: !0,
            is_custom: r,
            member_voucher_id: n,
            max_price: i,
            min_price: s
        }));
    },
    change: function(t) {
        this.setData({
            active: t.detail.index
        }), this.getData(1);
    },
    getData: function() {
        var e = this, a = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1, i = {
            page: a,
            status: this.data.active - 1
        };
        0 == this.data.active && delete i.status, t._postNetWork({
            url: t.getNetAddresss("plugin.consignment.frontend.controllers.member-exchange-voucher.index"),
            data: i,
            success: function(i) {
                var s = i.data, r = s.result, o = s.data, n = s.msg;
                if (console.log(i.data), console.log(o), r) {
                    var c = i.data.data, d = c.vember_voucher_list, u = c.plugin_name, l = [];
                    l = 1 == a ? d.data || [] : e.data.list.concat(d.data), e.data.page = d.current_page, 
                    e.data.total_page = d.last_page, e.setData({
                        list: l
                    }), wx.setNavigationBarTitle({
                        title: u
                    });
                } else t.tips(n);
            }
        });
    },
    getMoreData: function() {
        if (!(this.data.page >= this.data.total_page)) {
            var t = this.data.page + 1;
            this.getData(t);
        }
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getMoreData();
    },
    onShareAppMessage: function() {}
});